package com.itheima.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.domain.db.AnalysisByDay;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {

    //累计用户数
    @Select(" SELECT SUM(num_registered) FROM tb_analysis_by_day ")
    Long sumCumulativeUsers();

    @Select("SELECT SUM(num_active) FROM tb_analysis_by_day WHERE record_date BETWEEN #{beginDate} AND #{today}")
    Long selectActiveByTime(@Param("beginDate") String beginDate,@Param("today") String today);

    //根据起始和结束时间查询
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date BETWEEN #{beginDate} AND #{endDate}")
    List<AnalysisByDay> selectByTime(@Param("beginDate") String start, @Param("endDate") String end);
}